<?php

require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/wp-load.php';

if (isset($phonebook)) {
    if (isset($_POST["update_settings"]) && $_POST["update_settings"] = 'Y') {               
        // import new data
        if (isset($_FILES['data']['tmp_name']) && file_exists($_FILES['data']['tmp_name'])) {
            $xml = $phonebook->extractData(file_get_contents($_FILES['data']['tmp_name']));
            
            if ($xml != '') {
                header('Content-type: application/xml');
                header('Content-Disposition: attachment; filename="NewContacts.xml"');
                print $xml;
            }
            else {
                wp_die(sprintf(__('Not found new contacts')));
            }
        }
    }
}
